<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>活动查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <style>
        div {
            text-align: end;
        }
        a {
            margin-left: 10px;
            margin-right: 20px;
        }
        .box {
            width: 200px;
            display:block;
            text-align: center;
            margin: 100px auto 0;
        }
        input{
            margin: 5px 0px;
        }
        button{
            display: inline-block;
            margin: 5px 10px;
        }
        table{
            border-collapse: separate;
            border-spacing: 25px 5px;
        }
    </style>
</head>
<body>
<div>
    <span>欢迎，</span>
    <span th:text="${session.user.name}">User Name</span>
    <a href="/logout">退出</a>
</div>
<div class="box">
    <p>
        查询活动
    </p>
<input type="text" id="searchBox" placeholder="输入活动id查询">
<button id="searchButton">搜索活动</button>
<button id="addButton">添加活动</button>
<table>
    <tr>
        <th>ID</th>
        <th>Name</th>
    </tr>
    <tr th:each="activity : ${activityList}">
        <td th:text="${activity.actid}">ID</td>
        <td th:text="${activity.name}">Name</td>
    </tr>
</table>
</div>
</body>
<script>
    document.getElementById('searchButton').addEventListener('click', function() {
        var id = document.getElementById('searchBox').value;
        if(id) {
            window.location.href =  "/activity/"+id;
        }
    });
    document.getElementById('addButton').addEventListener('click', function() {
            window.location.href =  "/activity/add";
    });

</script>

</script>
<script th:inline="javascript">
    var activity = [[${activity1}]];
    if (activity === "没有此活动id") {
        alert("没有此活动id");
    }
    else {
        alert("查询到的活动名称为："+activity.name)
    }
</script>
</html>
